#!/bin/sh
#
# Small shell script to show how to start/stop Atomojo using jsvc
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/lib64/jvm/java-1.5.0-sun-1.5.0_update12
XEERKAT_HOME=/home/xeerkat/current
XEERKAT_CONF=/home/xeerkat/server.conf
DAEMON_HOME=$XEERKAT_HOME/jsvc
XEERKAT_USER=xeerkat

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/xmpp-server.pid

XEERKAT_OPTS=""
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$XEERKAT_HOME/jsvc/commons-daemon.jar:\
$XEERKAT_HOME/xeerkat-xmpp-server.jar

case "$1" in
  start)
    #
    # Start Xeerkat XMPP Server
    #
    $DAEMON_HOME/jsvc \
    -user $XEERKAT_USER \
    -home $JAVA_HOME \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $XEERKAT_HOME/server.out \
    -errfile '&1' \
    $XEERKAT_OPTS \
    -cp $CLASSPATH \
    org.xeerkat.xmpp.server.tools.Daemon \
    $XEERKAT_CONF
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;

  stop)
    #
    # Stop Xeerkat XMPP Server
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.xeerkat.xmpp.server.tools.Daemon
    exit $?
    ;;

  *)
    echo "Usage server.sh start/stop"
    exit 1;;
esac
